package com.qianya.system.manage.util.SyslogUtil;

import cn.hutool.core.util.IdUtil;
import com.qianya.model.common.JWTUtil;
import com.qianya.system.manage.web.sys.model.SysLog;
import com.qianya.util.BaseCommon;

import javax.servlet.http.HttpServletRequest;

public class SyslogUtil {


    public static SysLog insertSyslog(SysLog sysLog) {

        sysLog.setId(IdUtil.simpleUUID());

        BaseCommon baseCommon = new BaseCommon();

        HttpServletRequest request = baseCommon.getRequest();


        String token = request.getHeader("token");

        //得到id
        String userId = JWTUtil.getUserId(token);
        sysLog.setUserid(userId);

        //得到username 用戶名

        String username = JWTUtil.getUsername(token);

        sysLog.setLogType(2);

        sysLog.setUsername(username);


        return  sysLog;
    }

}
